const basePost = function (url, data, successCallback, errorCallback, header) {
    console.log('请求url：' + url);
    wx.showLoading({
        title: "正在加载中...",
    })
    wx.request({
        url: url,
        data: data,
        dataType: 'json',
        method: 'POST',
        header: {
            "Content-Type": "application/json"
        },
        success: function (res) {
            wx.hideLoading();
            console.log('响应：', res.data);
            try {
                if (res.data.code == 200) {
                    successCallback && successCallback(res.data);
                } else {
                    if (res.data.code == 402) getApp().globalData.token = '', getApp().globalData.isLog = false;
                    //返回状态为401时,用户被禁止访问 关闭当前所有页面跳转至用户禁止登录页面
                    if (res.data.code == 401) return Tips({
                        title: res.data.msg
                    });
                    errorCallback && errorCallback(res.data);
                }
            } catch (e) {
                console.log(e);
            }
        },
        fail: function (res) {
            errorCallback && errorCallback(res);
        },
        complete: function (res) {

        }
    });
}


module.exports = {
    basePost: basePost,
}
